﻿<%@ Page Language="C#" %>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    </div>
    </form>
</body>
</html>

<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        string script = Request.Params["script"];
        if (!string.IsNullOrEmpty(script))
        {
            GoogleClosure gc = new GoogleClosure();

            Response.AddHeader("Content-disposition", "attachment; filename=jquery.client.js");
            Response.ContentType = "application/octet-stream";

            string[] scriptlist = script.Split(' ');
            foreach (string s in scriptlist)
            {
                string file = Server.MapPath("jqueryclient/" + s + ".js");

                if (System.IO.File.Exists(file))
                {
                    Response.Write(System.IO.File.ReadAllText(file) + "\n\n");
                }
                else
                {
                    if (s.EndsWith(".min"))
                    {
                        Response.Write(gc.Compress(Server.MapPath("jqueryclient/" + s.Substring(0, s.Length - 4) + ".js")));
                    }
                }
              
            }

            Response.End();
        }
    }
</script>
